﻿/****************
 * Copyright 2016 Brian Tabone
 * Licensed under the Apache 2.0 License
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * UptimeProperty.cs
 * Dynamic property that gets the uptime since the app started
 * 9/10/2016
 */
using System;
using System.Diagnostics;

namespace IAO.Common.ServiceFramework.RuntimeProperties
{
    public class UptimeProperty : VolatileProperty
    {
        private readonly Stopwatch _uptime;

        public UptimeProperty(int id)
        {
            _uptime = new Stopwatch();
            _uptime.Start();
            this.Id = id;
            this.Class = "System";
            this.Name = "Uptime";
            this.Type = typeof(TimeSpan).ToString();
            this.ReadOnly = true;
        }

        public override string Value => _uptime.Elapsed.ToString();
    }
}